package com.example.lenovo.weiyi;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import butterknife.BindView;
import butterknife.ButterKnife;
import jcvideoplayer_lib.JCVideoPlayer;
import jcvideoplayer_lib.JCVideoPlayerStandard;
import share.HttpIP;


public class VideoXQActivity extends AppCompatActivity {

    @BindView(R.id.tv_videoxq_title)
    TextView tvVideoxqTitle;
    @BindView(R.id.tv_videoxq_content)
    TextView tvVideoxqContent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_xq);
        ButterKnife.bind(this);
        LayBack();
        init();
    }

    public void init() {
        ((TextView) findViewById(R.id.tv_lay_title))
                .setVisibility(View.VISIBLE);
        ((TextView) findViewById(R.id.tv_lay_title)).setText("视频详情");
        if (TextUtils.isEmpty(getIntent().getStringExtra("title"))) {
            tvVideoxqTitle.setVisibility(View.GONE);
        } else {
            tvVideoxqTitle.setText(getIntent().getStringExtra("title"));
            tvVideoxqTitle.setVisibility(View.VISIBLE);
        }
        tvVideoxqContent.setText(getIntent().getStringExtra("intro"));
        playVideo();
    }

    public void playVideo() {
        JCVideoPlayerStandard jcVideoPlayerStandard = (JCVideoPlayerStandard) findViewById(R.id.videoplayer);
//        jcVideoPlayerStandard.setUp("http://2449.vod.myqcloud.com/2449_22ca37a6ea9011e5acaaf51d105342e3.f20.mp4"
//                , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "");
        jcVideoPlayerStandard.setUp(HttpIP.Base_IpIMage + getIntent().getStringExtra("link")
                , JCVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "");
//        Uri uri=Uri.parse("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1497516840259&di=4525d78b5fd23f5e3c48c243d9e820ef&imgtype=0&src=http%3A%2F%2Fa.hiphotos.baidu.com%2Fzhidao%2Fwh%253D450%252C600%2Fsign%3D32fda00219d5ad6eaaac6ceeb4fb15ed%2Fcf1b9d16fdfaaf5113381a798e5494eef11f7a19.jpg");
//        jcVideoPlayerStandard.thumbImageView.setImageURI(uri);
    }

    @Override
    public void onBackPressed() {
        if (JCVideoPlayer.backPress()) {
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onPause() {
        super.onPause();
        JCVideoPlayer.releaseAllVideos();
    }

    //返回事件
    public void LayBack() {
        ((ImageView) findViewById(R.id.imv_lay_back)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
                overridePendingTransition(R.anim.pre_in, R.anim.pre_out);
            }
        });
    }
}
